//
//  LJJMyCell.m
//  shopTest
//
//  Created by 梁佳佳 on 2016/11/14.
//  Copyright © 2016年 梁佳佳. All rights reserved.
//

#import "LJJMyCell.h"

@interface LJJMyCell ()

@property (strong, nonatomic) UIImageView *iconImageView;    /** 图标 **/
@property (strong, nonatomic) UILabel *titleLabel;    /** 标题 **/
@property (strong, nonatomic) UIImageView *nextImageView;    /** 下一步 **/
@property (strong, nonatomic) UIView *lineView;    /** 分割线 **/

@end

@implementation LJJMyCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.iconImageView];
        [self addSubview:self.titleLabel];
        [self addSubview:self.nextImageView];
        [self addSubview:self.lineView];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    __weak typeof(self) weakSelf = self;
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.mas_left).offset(15);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(weakSelf);
        make.left.equalTo(weakSelf.iconImageView.mas_right).offset(15);
        make.width.equalTo(@150);
    }];
    [self.nextImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 15));
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.right.equalTo(weakSelf.mas_right).offset(-15);
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.equalTo(weakSelf);
        make.left.equalTo(weakSelf.titleLabel.mas_left);
        make.height.equalTo(@1);
    }];
}
- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}
- (void)setDic:(NSDictionary *)dic
{
    self.iconImageView.image = [UIImage imageNamed:dic[@"image"]];
    self.titleLabel.text = dic[@"name"];
}
#pragma mark -
#pragma mark - lazy method
- (UIImageView *)iconImageView
{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] init];
    }
    return _iconImageView;
}
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:15.0f];
        _titleLabel.textColor = [UIColor blackColor];
    }
    return _titleLabel;
}
- (UIImageView *)nextImageView
{
    if (!_nextImageView) {
        _nextImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"下一步"]];
    }
    return _nextImageView;
}
- (UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = MAINCOLOR;
    }
    return _lineView;
}
@end
